package com.tally.project.system.book.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.tally.framework.web.BaseEntity;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 账本对象 book
 * @author soul
 * @date 2023-08-02
 */
public class Book extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 用户ID */
    @ApiParam(hidden = true)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    @ApiParam(name = "账本名称", value = "name")
    private String name;

    @ApiParam(name = "账本类型编号", value = "serial")
    private Integer serial;

    @ApiParam(name = "账本图标", value = "icon")
    private String icon;

    @ApiParam(name = "默认使用：0.否 1.是", value = "state")
    private Integer state;

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }
    public void setUserId(Long userId)
    {
        this.userId = userId;
    }

    public Long getUserId()
    {
        return userId;
    }
    public void setName(String name)
    {
        this.name = name;
    }

    @NotNull(message = "请输入账本名称")
    @Size(min = 2, max = 20, message = "账本名称必须在2～20个字符之间")
    public String getName()
    {
        return name;
    }
    public void setIcon(String icon)
    {
        this.icon = icon;
    }

    public Integer getSerial() {
        return serial;
    }

    public void setSerial(Integer serial) {
        this.serial = serial;
    }

    public String getIcon() {
        return icon;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Book(Long id, Long userId, String name, int serial, String icon, int state) {
        this.id = id;
        this.userId = userId;
        this.name = name;
        this.serial = serial;
        this.icon = icon;
        this.state = state;
    }

    public Book(String name, Integer serial, String icon) {
        this.name = name;
        this.serial = serial;
        this.icon = icon;
    }

    public Book(Long userId, Integer state) {
        this.userId = userId;
        this.state = state;
    }

    public Book() {
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("userId", getUserId())
            .append("name", getName())
            .append("serial", getSerial())
            .append("icon", getIcon())
            .toString();
    }
}
